< previous page page_513 next page >

Page 513
the main reasons that Visual Basic provides the capability to set breakpoints. A breakpoint defines a statement or set of conditions (if set in a Watch/Break expression) at which Visual Basic will automatically stop the execution of the application and put it into Break mode without running the statement containing the breakpoint. You can enter Break mode by doing any of the following operations while the application is executing:
Press the Ctrl+Break keys
Choose Run, Break
Click Break on the toolbar
It's possible to suspend execution when the application is between processing of events. When this happens, execution does not stop at a specific line, but Visual Basic switches to Break mode anyway. You can also enter Break mode automatically whenever one of the following conditions occurs:
A statement generates a runtime error that was not handled by an error handler
A runtime error was generated and the Break on All Errors option was selected
A Break expression defined in the Add Watch dialog box changes or becomes True, depending on how you defined it
Execution encounters a line that contains a breakpoint
Execution reaches a Stop statement
Setting a breakpoint in your application code can be done one of three ways, as shown in the following list:
Select the statement and choose Debug, Toggle Breakpoint from the menu, or hit the F9 shortcut key.
Select the statement and then right-click it. From the pop-up menu, choose Toggle, Breakpoint.
Click the mouse in the border to the left of the statement.
When a breakpoint is set, Visual Basis will highlight the selected line in bold, using the colors specified in the Editor Format tab on the Options dialog box from the Tools menu. Additionally, Visual Basic will also highlight the current statement in the code window. Both of these highlights are shown in Figure 18.9 with the associated margin indicators as well.
After you reach a breakpoint and the application has stopped, you can examine the application's current condition by moving the focus among the forms and modules of your application, the Code window, and the debugging windows. A breakpoint stops the application just before executing the line that contains the breakpoint. If you want to observe

 
< previous page page_513 next page >

If you like this book, buy it!